﻿
@{
    ViewBag.Title = "AddUser";
    Layout = "~/Views/Shared/_LayoutPay.cshtml";
}
@using Pay.Model.Model
@model List<MenuInfo>
<link href="~/Content/layui.css" rel="stylesheet" />
@section scripts{
    <script src="~/Scripts/jquery.unobtrusive-ajax.min.js"></script>
    <script src="~/Scripts/layer.js"></script>
    <script>
        function addSuccess(data)
        {
            parent.layer.msg(data.msg);
        }
    </script>
}
   @{ 
             var list= (List<RoleMenuInfo>)ViewBag.Allhave;
   }
<div class="ibox-content">
    @using (Ajax.BeginForm("EditRole", null, new AjaxOptions { HttpMethod = "post", OnSuccess = "addSuccess", UpdateTargetId = "articles", InsertionMode = InsertionMode.Replace }, new { id = "search", @class = "form-horizontal" }))
    {
        <input type="hidden" value="@ViewBag.Id" name="RoleId" />
        <div class="form-group">
            <label class="col-sm-3 control-label">角色名称：</label>
            <div class="col-sm-8">
                <input type="text" value="@ViewBag.Name" placeholder="角色名称" class="form-control" name="RoleName" maxlength="18" required>
            </div>
        </div>
        <div class="form-group">
            <label class="col-sm-3 control-label">描述：</label>
            <div class="col-sm-8">
                <textarea placeholder="描述"  class="form-control" name="Description" required>@ViewBag.Des</textarea>
            </div>
        </div>
        <div class="form-group">
            <label class="col-sm-3 control-label">菜单列表：</label>
            <div class="col-sm-8">

                @if (Model != null && Model.Any())
                {

                    foreach (var item in Model)
                    {
                        var temp = list.Where(c => c.MenuId == item.Id).FirstOrDefault();
                        if (temp == null)
                        {
                            <input type="checkbox" value="@item.Id" id="@item.Id" name="MenuIds"><label for="@item.Id">@item.MenuName</label>
                        }
                        else
                        {
                            <input type="checkbox" checked="checked" value="@item.Id" id="@item.Id" name="MenuIds"><label for="@item.Id">@item.MenuName</label>
                        }


                    }
                }

            </div>
        </div>
        <div class="form-group">
            <div class="col-sm-offset-3 col-sm-8">
                <input class="btn btn-primary" type="submit" value="保存">
                <input class="btn btn-restore" type="reset" value="取消">
            </div>
        </div>
    }
</div>